import React from 'react'
// ===================================================================== Temp
import SubmitForm from '#cpt/temp/SubmitForm'
// ===================================================================== global declare
const { $Lazy } = window
// ===================================================================== Lazy
const Box 				= $Lazy.load(()=>import('#tp/box/box'))
const OtherParamsTable 	= $Lazy.load(()=>import('./table/other-params'))
// ===================================================================== component
class Index extends React.Component{
	state = {
		data: [],
		// 提交表单列表
		formData : [
			{ label: '方法以及局限性',					name: 'mod_limit', 			half:true, type:'textarea' },
			{ label: '方法以及局限性（英文）',			name: 'mod_limit_en', 		half:true, type:'textarea' },
			{ label: '项目优势',							name: 'pro_benefit', 		half:true, type:'textarea' },
			{ label: '项目优势（英文）',					name: 'pro_benefit_en', 	half:true, type:'textarea' },
			{ label: '参考文献',							name: 'refer', 				half:true, type:'textarea' },
			{ label: '参考文献（英文）',					name: 'refer_en', 			half:true, type:'textarea' },
			{ label: '项目说明（报告单注释内容）',		name: 'desc', 				half:true, type:'textarea' },
			{ label: '项目说明（报告单注释内容英文）',	name: 'desc_en', 			half:true, type:'textarea' },
		],
	}
	
	componentDidMount(){
		
	}
	
	onSubmit = () => this.formRef.submit()
	
	fetch = () => {
		const { kind_id } = this.props
		this.submit = { kind_id }
		window.$http.pull(this,'report-cats/info', { param:{ kind_id }, dataName:null} ).then(({info, param})=>{
			this.formRef.setValue(info)
			this.setState({ data: param})
		})
	}
	
	render(){
		const { edit, kind_id } = this.props
		return (
			<>
				<Box title='报告单特性' contentClassName='pt10 pl20' first>
					{ SubmitForm.call(this,{ msg:'保存', labelWidth:'x100', api:'report-cats/editreport', onForm: this.fetch, disabled:edit, onOk:this.props.onAudit }) }
				</Box>
				{/* 其他参数 */}
				<OtherParamsTable kind_id={kind_id} pagingLoading={this.state.pullLoading} data={this.state.data} disabled={edit} onRefresh={this.fetch}/>
			</>
		)
	}
}

export default Index